<?php

use yii\db\Migration;

/**
 * Class m190927_072602_information
 */
class m190927_072602_information extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="资讯列记录表"';
        $this->createTable('{{%information}}', [
            'id' => $this->primaryKey(),
            'title' => $this->string()->notNull()->comment('标题'),
            'mid' => $this->integer()->notNull()->comment('分类id'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('资讯列状态 1：正常启用 2：停用'),
            'is_recommend'=> $this->smallInteger()->notNull()->defaultValue(2)->comment('是否推荐 1：推荐 2：不推荐'),
            'pic' => $this->string()->notNull()->comment('封面图'),
            'project_id'=> $this->integer()->comment('关联项目id'),
            'user_id' =>  $this->integer()->notNull()->comment('发布人ID'),
            'info' => $this->text()->comment('资讯详情'),
            'describe'=>$this->text()->notNull()->comment('简介'),
            'click_num' => $this->bigInteger()->defaultValue(0)->comment('查看次数'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%information}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190927_072602_information cannot be reverted.\n";

        return false;
    }
    */
}
